package com.oocl.server;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;



public class SCPServer {
	
	
     public static void main(String[] args) throws IOException {
    	 ServerSocket  server =  new ServerSocket(8888);
 		 System.out.println("Server start.....");
 		SolveResponce sr = new SolveResponce();
 		 while(true){
 		           Socket socket= server.accept();
 		 
 		           InputStream in = socket.getInputStream();
 		           BufferedReader reader = new BufferedReader(new InputStreamReader(in));
 		           OutputStream out = socket.getOutputStream();
 		           out.write("Connecting  Success!\n".getBytes());
 		           while(true){
 		        	   String opration = reader.readLine();
 		        	   switch(opration){
 		        	      case "scp":{
 		        	    	 sr.solveSCP(reader,in,out);
 		        	    	  break;
 		        	    	  
 		        	      }
 		        	      case "ls":{
 		        	    	 sr.solveLS(out);
 		        	    	  break;
 		        	    	  
 		        	      }
 		        	      case "rm":{
 		        	    	 sr.solveRM(reader,out);
 		        	    	  
 		        	    	
 		        	    	  break;
 		        	    	  
 		        	      }
 		        	      default:continue; 
 		        	   }
 		        	   
 		           }
 		           
 		           
         }
     }
     
    

     
}

